﻿Public Class MIDI

    Public Const MicroSecondsPerMinute As Long = 60000000

    Public Property Header As MThd
    Public Property Track As MTrk()

    Private Sub New()

    End Sub

    Public Shared Function FromStream(S As Stream) As MIDI

        Dim InputReader As New BigEndianBinaryReader(S)
        Dim Result As New MIDI

        Result.Header = MThd.FromStream(InputReader)

        ReDim Result.Track(Result.Header.TrackCount - 1)
        For I As Integer = 0 To Result.Header.TrackCount - 1
            Result.Track(I) = MTrk.FromStream(InputReader)
        Next

        InputReader.Close()

        Return Result

    End Function

End Class
